package com.tsingtree.modular.controller.view;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tsingtree.base.auth.context.LoginContextHolder;
import com.tsingtree.base.auth.model.LoginUser;
import com.tsingtree.modular.entity.NanDeviceCate;
import com.tsingtree.modular.entity.NanSellerTag;
import com.tsingtree.modular.enums.*;
import com.tsingtree.modular.service.NanDeviceCateService;
import com.tsingtree.modular.service.NanSellerTagService;
import com.tsingtree.roses.core.base.controller.BaseController;
import com.tsingtree.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 广告栏控制器
 *
 * @author jagger
 */
@RestController
@RequestMapping("/enums")
public class CommonEnumController extends BaseController {

    @Autowired
    private NanDeviceCateService nanDeviceCateService;
    @Autowired
    private NanSellerTagService nanSellerTagService;

    @RequestMapping("/tags")
    public ResponseData tags() {
        Map<Integer, String> map = nanSellerTagService.list(new QueryWrapper<NanSellerTag>()
                        .eq("is_del", false))
                .stream().collect(Collectors.toMap(NanSellerTag::getId, NanSellerTag::getName));
        return ResponseData.success(map);
    }
    @RequestMapping("/commonStatus")
    public ResponseData commonStatus() {
        return ResponseData.success(CommonStatusEnum.getAll());
    }
    @RequestMapping("/paramType")
    public ResponseData paramType() {
        return ResponseData.success(ParamTypeEnum.getAll());
    }
    @RequestMapping("/announceMsgType")
    public ResponseData announceMsgType() {
        return ResponseData.success(SellAnnounceMsgTypeEnum.getAll());
    }
    @RequestMapping("/feedbackStatus")
    public ResponseData feedbackStatus() {
        return ResponseData.success(FeedbackStatusEnum.getAll());
    }
    @RequestMapping("/noticeTypes")
    public ResponseData noticeTypes() {
        return ResponseData.success(NoticeTypeEnum.getAll());
    }
    @RequestMapping("/sexTypes")
    public ResponseData sexTypes() {
        return ResponseData.success(SexTypeEnum.getAll());
    }
    @RequestMapping("/gameTypes")
    public ResponseData gameTypes() {
        return ResponseData.success(GameTypeEnum.getAll());
    }
    @RequestMapping("/checkStatus")
    public ResponseData checkStatus() {
        return ResponseData.success(CheckStatusEnum.getAll());
    }
    @RequestMapping("/sceneTypes")
    public ResponseData sceneTypes() {
        return ResponseData.success(SceneTypeEnum.getAll());
    }
    @RequestMapping("/playStatus")
    public ResponseData playStatus() {
        return ResponseData.success(PlayStatusEnum.getAll());
    }
    @RequestMapping("/deviceCate")
    public ResponseData deviceCate() {
        Map<Integer, String> map = nanDeviceCateService.list(new QueryWrapper<NanDeviceCate>().eq("is_del", false))
                .stream().collect(Collectors.toMap(NanDeviceCate::getId, NanDeviceCate::getName));
        return ResponseData.success(map);
    }
    @RequestMapping("/productTypes")
    public ResponseData productTypes() {
        return ResponseData.success(ProductTypeEnum.getAll());
    }
    @RequestMapping("/userTags")
    public List<Map<String, Object>> userTags() {
        List<NanSellerTag> tags = nanSellerTagService.list(new QueryWrapper<NanSellerTag>()
                .eq("is_del", false));
        List<Map<String, Object>> list = new ArrayList<>();
        tags.forEach((tag) -> {
            Map<String, Object> map = new HashMap<>();
            map.put("id", "-" + tag.getId() + "-");
            map.put("name", tag.getName());
            list.add(map);
        });
        return list;

    }

    @RequestMapping("/reviewRating")
    public ResponseData reviewRating() {
        Map<Integer, String> ratings = new HashMap<>();
        ratings.put(1, "1星");
        ratings.put(2, "2星");
        ratings.put(3, "3星");
        ratings.put(4, "4星");
        ratings.put(5, "5星");
        return ResponseData.success(ratings);
    }
}


